<?php
class Modules_Common_Design_Rows
{
	var $columns;
	public $style="";
	public function Modules_Common_Design_Rows(Modules_Common_Design_RowsHeader $header)
	{
	 	foreach($header->header_rows as $key=>$value)
	 		$this->columns[$value]=1;
	}
	public function addColumn($value)
	{
		if(!is_array($value))
			throw new Exception("Invalid Column argument");
		if(!isset($this->columns[key($value[0])]))
			throw new Exception("Invalid Column Name");
		$this->columns[key($value[0])]=$value[0];
		
	}
	
	public function __toString()
    {
       $str="";
       foreach($this->columns as $key=>$value)
       		$str.= "<td class='".$this->style."'>".$value."</td>";
    	
       	return $str;
    }
	
	public function setRow($array)
	{
		if(!is_array($array))
			throw new Exception("Invalid Column argument");
		if(count($array)!=count($this->columns))
			throw new Exception("Invalid Column number");
		
		foreach($array as $key=>$value)
			$this->columns[$key]=$value;	
	}
	public function setAction($column,Modules_Common_Design_Action $Action)
	{
		if(!isset($this->columns[$column]))
			throw new Exception("Invalid Column Name");
		$this->columns[$column]=$Action->DoIt();
	}

}
?>